import 'package:flutter/material.dart';
import 'package:leader_help/utils/component/dragable/view.dart';
import 'package:leader_help/utils/util.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'controller.dart';

class TabPage extends GetView<TbController> {
  const TabPage({Key? key}) : super(key: key);

  Widget getIcon(String url) {
    return Image.asset(
      url.imgPathTabbar,
      width: 18.w,
      height: 18.w,
      fit: BoxFit.contain,
    );
  }

  @override
  Widget build(BuildContext context) {
    SizeFit.initialize();
    return Obx(
      () => Scaffold(
          body: Stack(
            children: [
              IndexedStack(
                index: controller.state.currentIndex.value,
                children: controller.state.pages,
              ),
              DragablePage(
                  child: Container(
                    width: 50.r,
                    height: 50.r,
                    decoration: BoxDecoration(
                      color: ColorsUtil.red,
                      borderRadius: BorderRadius.circular(25.r),
                      boxShadow: [
                        BoxShadow(
                            color: ColorsUtil.red.withAlpha(80),
                            offset: const Offset(1, 2)),
                        BoxShadow(
                            color: ColorsUtil.red.withAlpha(60),
                            offset: const Offset(2, 3)),
                      ],
                    ),
                    child: Icon(
                      ProIconUtil.audio,
                      color: Colors.white,
                      size: 30.r,
                    ),
                  ),
                  onTap: () {})
            ],
          ),
          bottomNavigationBar: BottomNavigationBar(
            type: BottomNavigationBarType.fixed,
            selectedItemColor: ColorsUtil.theme,
            unselectedItemColor: ColorsUtil.subTitle,
            items: controller.state.items
                .map((e) => BottomNavigationBarItem(
                    label: e.title,
                    icon: getIcon(e.icon),
                    activeIcon: getIcon(e.activeIcon)))
                .toList(),
            currentIndex: controller.state.currentIndex.value,
            selectedFontSize: 12,
            unselectedFontSize: 12,
            onTap: (index) => controller.clickTab(index),
            backgroundColor: Colors.white,
          )),
    );
  }
}
// PageView(
//             physics: const NeverScrollableScrollPhysics(),
//             controller: controller.state.pageController,
//             children: controller.state.pages,
//           )
